package com.josn.controller;

import com.josn.pojo.Article;
import com.josn.pojo.PageBean;
import com.josn.pojo.Result;
import com.josn.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    //新增文章
    @PostMapping
    public Result add(@RequestBody Article article){
        articleService.add(article);
        return Result.success();
    }

    //文章列表
    @GetMapping
    public Result<PageBean<Article>> list(
            Integer page_num,
            Integer page_size,
            @RequestParam(required = false) Integer category_id,
            @RequestParam(required = false)String state
    ){
        PageBean<Article> pb=articleService.list(page_num,page_size,category_id,state);
        return Result.success(pb);
    }

    //获取文章详情
    //更新文章
    //删除文章
}
